Part Number Hot Search : 
34063AP X25L64 FK10000 74LS10 CX168 25TTS XCA170S EN25Q32
Product Description
Full Text Search
 

To Download AN1043 Datasheet File

  If you can't view the Datasheet, Please click here to try to view without PDF Reader .  
 
 


  Datasheet File OCR Text:
  ? 2006 microchip technology inc. ds01043a-page 1 AN1043 introduction gpio expanders provide easy i/o expansion using standard serial interfaces. gpio products are used to increase the i/o on an mcu or provide remote i/o using a serial interface. this application note discusses the feature set and use of the mcp23x08/17 (8-bit and 16-bit) gpio expand- ers. the mcp23x08 are 8-bit gpio expanders: ? mcp23008: i 2 c? interface ? mcp23s08: spi interface the mcp23x17 are 16-bit gpio expanders: ? mcp23017: i 2 c interface ? mcp23s17: spi interface the functions and features of the mcp23x08 and mcp23x17 are basically the same, except where otherwise noted. features this application note discusse s some of the features of the mcp23x08/17 and how they may be used in an application: ? i/o port description ? 8/16-bit mode (mcp23x17 only) ? interrupt features - mapping interrupts - mirroring interrupts (mcp23x17 only) - servicing interrupts ? internal address pointer control ? hardware address pin on spi i/o port description the i/o port is highly configurable for maximum flexibility. figure 1 is a simplified block diagram of an i/o port pin. the port can either drive logic levels on the pin, or read logic levels from the pad. the level on the pad can be read at any time, regardless if the pin is configured as an input or an output. the iodir register controls the direction of the pins (input or output). more spec ifically, the iodir registers simply enables/disables the output driver. when the driver is activated (iodir = 0), the pad is driven to the state in the latch register (olat). when deactivated (iodir = 1), the driver is high impedance. the i/o port has multiple, individual configurations. each pin can ? be configured as an input. the output driver is disabled (high impedance) ? be configured as an outp ut. the output driver is enabled and the value in the latch is driven on the pin. ? enable a weak pull-up resistor ? emulate an open-drain configuration. this is accomplished by clearing the output latch (olat) bit to a zero and using the direction register (iodir) to set the level on the pin. a pull-up resistor is required to pull the pin to voltage when the pin is an input - to drive a 0: configur e the pin as an output (iodir = 0) so the port drives whatever is in olat (logic 0 in this case) - to float a 1: set the pin as an input (iodir = 1). the output driver is disabled and the pull-up resistor pulls the pin to a logic 1 author: pat richards microchip technology inc. unique features of the mcp23x08/17 gpio expanders
AN1043 ds01043a-page 2 ? 2006 microchip technology inc. figure 1: i/o port block diagram 8/16 bit mode (mcp23x17 only) the mcp23x17 has the unique ability to appear to the mcu as either two (2) 8-bit gpio expanders, or as a single 16-bit gpio expander. this is accomplished by splitting the 16 i/o ports into two separate 8-bit i/o ports (port a and port b) via iocon.bank. each port has a group of dedicated registers. table 1 shows how the register groups (port a and port b) are mapped when in 8-bit or 16-bit mode. 8-bit mode: when in 8-bit mode, the ports? registers are separated: ? port a register addresses range from 00h ? 0ah ? port b register addresses range from 10h ? 1ah 16-bit mode: when in 16-bit mode, the ports? registers are interleaved to emulate 16-bit wide registers: ? port a and port b register addresses range from 00h ? 15h. the registers are still addressed as 8-bit ports, meaning that the 16-bit mapping pair is always an even number (e.g., iodir starts at 00h, ipol starts at 02h, etc.) table 1: memory map note: unlike all other registers which are not shared between the two ports (port a and port b), there is one register (iocon). which is shared between the ports and affects both equally. q q set clr d q q set clr d q q set clr d input buffer olat or gpio iodir data bus write write read port i/o pad v dd mcp23x08/17 8-bit mode 16-bit mode register name address (hex) register name address (hex) iodira 00 iodira 00 ipola 01 iodirb 01 gpintena 02 ipola 02 defvala 03 ipolb 03 intcona 04 gpintena 04 iocon 05 gpintenb 05 gppua 06 defvala 06 intfa 07 defvalb 07 intcapa 08 intcona 08 gpioa 09 intconb 09 olata 0a iocon 0a iodirb 10 iocon 0b ipolb 11 gppua 0c gpintenb 12 gppub 0d defvalb 13 intfa 0e intconb 14 intfb 0f iocon 15 intcapa 10 gppua 16 intcapb 11 intfb 17 gpioa 12 intcapb 18 gpiob 13 gpiob 19 olata 14 olatb 1a olatb 15
? 2006 microchip technology inc. ds01043a-page 3 AN1043 interrupt features the mcp23x08 has one interrupt pin and the mcp23x17 has two interrupt pins. for the mcp23x17, each interrupt pin is associated with an 8-bit port. inta is associated with port a and intb is associated with port b. interrupt mapping the mcp23x17 interrupt pins can be mapped in two ways (see figure 2) as controlled by iocon.mirror: 1. interrupt pins operate independently. inta reflects interrupt conditions on port a and intb reflects interrupt conditions on port b. 2. both interrupt pins go active when an interrupt occurs on either port. interrupt polarity and open-drain the interrupts can be configured to operate in three modes: 1. active-high. 2. active-low. 3. open-drain. the interrupt polarity and open-drain is configured via intpol and odr bits in the iocon register. interrupt conditions there are several configurable interrupt conditions which allow flexible configurations. interrupt-on-pin-change pins configured for interrupt-on-pin-change will cause an interrupt to occur if a pin changes to the opposite state. the default state is reset after an interrupt is serviced. for example, an interrupt occurs by an input changing from 1 to 0 . the interrupt is then serviced while the pin state is still 0 by reading gpio or intcap register. the new initial state for the pin is a logic 0 . likewise, if the pin is toggled back to a logic 1 before servicing the interrupt, the new default state is a logic 1 . the interrupt condition is cleared by reading either intcap or gpio register. the new pin state default is set when the interrupt is cleared. interrupt-on-change from defval register value pins configured for interrupt-on-change from register value will cause an interrupt to occur if the corresponding input pin differs from the register bit. the interrupt condition will remain as long as the condition exists, regardless if the intcap or gpio is read. for example, if defval = 0 . an interrupt will occur if the pin changes to a logic 1 and the interrupt will remain as long as the pin remains a logic 1 . the interrupt condition will clear if the pin changes back to a logic 0 and intcap or gpio is read. figure 2: interrupt block diagram note: for the mcp23x17, the polarity and open- drain configuration of the inta and intb pins are not independent. both pins are configured the same. polarity control inta intb open- drain control a b 0 1 0 1 iocon.mirror iocon.intpol iocon.odr
AN1043 ds01043a-page 4 ? 2006 microchip technology inc. figure 3: interrupt-on-pin-change example figure 4: interrupt-on-change-from-defval example gp3 int spi read intcap or gpio change cause interrupt. port state captured in intcap no affect on int pin or intcap interrupt cleared and re-enabled change cause interrupt. port state captured in intcap read intcap or gpio given: - gp3 configured to ?interrupt-on-pin-change? - int pin configured for ?active low? ioc7 ioc6 ioc5 ioc4 ioc3 ioc2 ioc1 ioc0 intcon ? interrupt control register x x x x 1 x x x def7 def6 def5 def4 def3 def2 def1 def0 defval ? default value register x x x x 0 x x x gpinten ? gpio interrupt-o n-change enable register x x x x 1 x x x gpint7 gpint6 gpint5 gpint4 gpint3 gpint2 gpint1 gpint0 interrupt will occur if gp3 logic level = 1 int gp3 spi read intcap or gpio read intcap or gpio change cause interrupt. port state captured in intcap no affect on int pin or intcap int remains because gp3 = 1 (opposite of def3) gp3 = def3 int deactivates after spi read
? 2006 microchip technology inc. ds01043a-page 5 AN1043 internal address pointer control some slave serial devices automatically increment their internal address pointer after each byte is clocked by the master. this allows the master to sequentially access multiple registers without re-sending the write or read command. other slave devices do not automatically increment their internal address pointer. the mcp23x08/17 family of devices have the ability to do either by configuring a control bit (iocon.seqop). this allows maximum flexibility when accessing the registers. for example, when configur ing the device, it may be desirable to allow the address pointer to automatically increment so the device does not have to be re- addressed after every byte. likewise, when performing a continuous operation on a register (e.g., changing the outputs on a regular basis by writing to gpio or olat), it may be beneficial to disable the address incrementing feature so that the register is always accessed without re-addressing the register. figure 5: 8-bit mode: address poin ter disabled (mcp23008 example) 0 1 0 0 a a a 0 a s 0 0 0 0 1 1 0 0 a 1 0 1 0 1 1 0 0 a 0 1 0 1 0 0 1 1 a 1 0 1 0 1 1 0 0 p mcp23x08 opcode register addr = 09h data @ 09h data @ 09h data @ 09h when the address pointer is disabled and the device is in 8-bit mode, the address pointer will not increment the address pointer. gpioa 09 olata 0a iodirb 10 ipolb 11 gpintenb 12 defvalb 13 intconb 14 iocon 15 gppub 16 intfb 17 intcapb 18 gpiob 19 olatb 1a see figure 5 and figure 6 for address pointer examples for the mcp23x08 8-bit devices and figure 7 and figure 8 for the mcp23x17 examples.
AN1043 ds01043a-page 6 ? 2006 microchip technology inc. figure 6: 8-bit mode: address pointer enabled (mcp23008 example) figure 7: 16-bit mode: address poin ter disabled (mcp23017 example) 0 1 0 0 a a a 0 a s 0 0 0 0 1 1 0 0 a 1 0 1 0 1 1 0 0 a 0 1 0 1 0 0 1 1 a 1 0 1 0 1 1 0 0 p mcp23x08 opcode register addr = 09h data @ 09h data @ 0ah data @ 10h when the address pointer is enabled and the device is in 8-bit mode, the address pointer will increment after every byte is clocked. the address pointer will roll over to 00h after exceeding 1ah (which is the last location of port b). gpioa 09 olata 0a iodirb 10 ipolb 11 gpintenb 12 defvalb 13 intconb 14 iocon 15 gppub 16 intfb 17 intcapb 18 gpiob 19 olatb 1a note: the address pointer jumps from 0ah to 10h when transitioning from port a to port b 0 1 0 0 a a a 0 a s 0 0 0 1 0 1 0 0 a 1 0 1 0 1 1 0 0 a 0 1 0 1 0 0 1 1 a 1 0 1 0 1 1 0 0 p mcp23x17 opcode register addr = 12h data @ 12h data @ 13h data @ 12h intconb 09 iocon 0a iocon 0b gppua 0c gppub 0d intfa 0e intfb 0f intcapa 10 intcapb 11 gpioa 12 gpiob 13 olata 14 olatb 15 when the address pointer is disabled and the device is in 16-bit mode, the address pointer will alternate between the register pair. also, the initial address can be either register address (e.g., 14h or 15h) and the pointer will still alternate between the registers.
? 2006 microchip technology inc. ds01043a-page 7 AN1043 figure 8: 16-bit mode: address po inter enabled (mcp23017 example) 0 1 0 0 a a a 0 a s 0 0 0 1 0 1 0 0 a 1 0 1 0 1 1 0 0 a 0 1 0 1 0 0 1 1 a 1 0 1 0 1 1 0 0 p mcp23x17 opcode register addr = 12h data @ 12h data @ 13h data @ 14h intconb 09 iocon 0a iocon 0b gppua 0c gppub 0d intfa 0e intfb 0f intcapa 10 intcapb 11 gpioa 12 gpiob 13 olata 14 olatb 15 when the address pointer is enabled and the device is in 16-bit mode, the address pointer will increment after every byte is clocked. the address pointer will roll over to 00h after exceeding 15h.
AN1043 ds01043a-page 8 ? 2006 microchip technology inc. hardware address pins address pins are typically used on i 2 c devices to allow multiple devices with the same base slave address to operate on the bus. slave devices with spi interfaces typically use only a chip select pin to select the device. this requirement consumes one mcu pin for every spi device on the bus. the ?s? devices (mcp23s08 and mcp23s17) have spi interfaces. these devices use a chip select for selecting the part, however, these parts also have hard- ware address pins, thereby giving the advantage of attaching multiple devices on the bus while only consuming one mcu pin for chip select (see figure 9). figure 9: address pins on spi devices summary the mcp23x08/17 family of gpio expanders have some unique features, giving the system and module engineer maximum flexibility when designing with the mcp23x08/17. cs sck sdi sdo spi a2 a1 a0 addr pins gpio port gp15 . . . . . . . gp0 0 1 0 0 1 0 0 0 a s 0 0 0 0 1 1 0 0 a mcp23x17 opcode register addr a2 a1 a0 mcp23s17 a1 a0 mcp23s08 gp7 . . . gp0 mcp23s08
? 2006 microchip technology inc. ds01043a-page 9 information contained in this publication regarding device applications and the like is prov ided only for your convenience and may be superseded by updates. it is your responsibility to ensure that your application me ets with your specifications. microchip makes no representations or warranties of any kind whether express or implied, written or oral, statutory or otherwise, related to the information, including but not limited to its condition, quality, performance, merchantability or fitness for purpose . microchip disclaims all liability arising from this information and its use. use of microchip devices in life support and/or safe ty applications is entirely at the buyer?s risk, and the buyer agrees to defend, indemnify and hold harmless microchip from any and all damages, claims, suits, or expenses resulting fr om such use. no licenses are conveyed, implicitly or ot herwise, under any microchip intellectual property rights. trademarks the microchip name and logo, the microchip logo, accuron, dspic, k ee l oq , micro id , mplab, pic, picmicro, picstart, pro mate, powersmart, rfpic, and smartshunt are registered trademarks of microc hip technology incorporated in the u.s.a. and other countries. amplab, filterlab, migratable memory, mxdev, mxlab, seeval, smartsensor and the embedded control solutions company are registered tradema rks of microchip technology incorporated in the u.s.a. analog-for-the-digital age, application maestro, dspicdem, dspicdem.net, dspicworks, ecan, economonitor, fansense, flexrom, fuzzyl ab, in-circuit serial programming, icsp, icepic, linear active thermistor, mindi, miwi, mpasm, mplib, mplink, pickit, picdem, picdem.net, piclab, pictail, powercal, powerinfo, powermate, powertool, real ice, rflab, rfpicdem, select mode, smart serial, smarttel, total endurance, uni/o, wiperlock and zena are trademarks of microchip technology incorporated in the u.s.a. and other countries. sqtp is a service mark of mi crochip technology incorporated in the u.s.a. all other trademarks mentioned herein are property of their respective companies. ? 2006, microchip technology incorporated, printed in the u.s.a., all rights reserved. printed on recycled paper. note the following details of the code protection feature on microchip devices: ? microchip products meet the specification cont ained in their particular microchip data sheet. ? microchip believes that its family of products is one of the mo st secure families of its kind on the market today, when used i n the intended manner and under normal conditions. ? there are dishonest and possibly illegal meth ods used to breach the code protection fe ature. all of these methods, to our knowledge, require using the microchip pr oducts in a manner outside the operating specif ications contained in microchip?s data sheets. most likely, the person doing so is engaged in theft of intellectual property. ? microchip is willing to work with the customer who is concerned about the integrity of their code. ? neither microchip nor any other semiconduc tor manufacturer can guarantee the security of their code. code protection does not mean that we are guaranteeing the product as ?unbreakable.? code protection is constantly evolving. we at microchip are committed to continuously improving the code protection features of our products. attempts to break microchip?s c ode protection feature may be a violation of the digital millennium copyright act. if such acts allow unauthorized access to your softwa re or other copyrighted work, you may have a right to sue for relief under that act. microchip received iso/ts-16949:2002 certification for its worldwide headquarters, design and wafer fabrication facilities in chandler and tempe, arizona, gresham, oregon and mountain view, california. the company?s quality system processes and procedures are for its picmicro ? 8-bit mcus, k ee l oq ? code hopping devices, serial eeproms, microperipherals, nonvolatile memory and analog products. in addition, microchip?s quality system for the design and manufacture of development syst ems is iso 9001:2000 certified.
ds00000a-page 10 ? 2006 microchip technology inc. americas corporate office 2355 west chandler blvd. chandler, az 85224-6199 tel: 480-792-7200 fax: 480-792-7277 technical support: http://support.microchip.com web address: www.microchip.com asia pacific office suites 3707-14, 37th floor tower 6, the gateway habour city, kowloon hong kong tel: 852-2401-1200 fax: 852-2401-3431 atlanta alpharetta, ga tel: 770-640-0034 fax: 770-640-0307 boston westborough, ma tel: 774-760-0087 fax: 774-760-0088 chicago itasca, il tel: 630-285-0071 fax: 630-285-0075 dallas addison, tx tel: 972-818-7423 fax: 972-818-2924 detroit farmington hills, mi tel: 248-538-2250 fax: 248-538-2260 kokomo kokomo, in tel: 765-864-8360 fax: 765-864-8387 los angeles mission viejo, ca tel: 949-462-9523 fax: 949-462-9608 san jose mountain view, ca tel: 650-215-1444 fax: 650-961-0286 toronto mississauga, ontario, canada tel: 905-673-0699 fax: 905-673-6509 asia/pacific australia - sydney tel: 61-2-9868-6733 fax: 61-2-9868-6755 china - beijing tel: 86-10-8528-2100 fax: 86-10-8528-2104 china - chengdu tel: 86-28-8676-6200 fax: 86-28-8676-6599 china - fuzhou tel: 86-591-8750-3506 fax: 86-591-8750-3521 china - hong kong sar tel: 852-2401-1200 fax: 852-2401-3431 china - qingdao tel: 86-532-8502-7355 fax: 86-532-8502-7205 china - shanghai tel: 86-21-5407-5533 fax: 86-21-5407-5066 china - shenyang tel: 86-24-2334-2829 fax: 86-24-2334-2393 china - shenzhen tel: 86-755-8203-2660 fax: 86-755-8203-1760 china - shunde tel: 86-757-2839-5507 fax: 86-757-2839-5571 china - wuhan tel: 86-27-5980-5300 fax: 86-27-5980-5118 china - xian tel: 86-29-8833-7250 fax: 86-29-8833-7256 asia/pacific india - bangalore tel: 91-80-4182-8400 fax: 91-80-4182-8422 india - new delhi tel: 91-11-5160-8631 fax: 91-11-5160-8632 india - pune tel: 91-20-2566-1512 fax: 91-20-2566-1513 japan - yokohama tel: 81-45-471- 6166 fax: 81-45-471-6122 korea - gumi tel: 82-54-473-4301 fax: 82-54-473-4302 korea - seoul tel: 82-2-554-7200 fax: 82-2-558-5932 or 82-2-558-5934 malaysia - penang tel: 60-4-646-8870 fax: 60-4-646-5086 philippines - manila tel: 63-2-634-9065 fax: 63-2-634-9069 singapore tel: 65-6334-8870 fax: 65-6334-8850 taiwan - hsin chu tel: 886-3-572-9526 fax: 886-3-572-6459 taiwan - kaohsiung tel: 886-7-536-4818 fax: 886-7-536-4803 taiwan - taipei tel: 886-2-2500-6610 fax: 886-2-2508-0102 thailand - bangkok tel: 66-2-694-1351 fax: 66-2-694-1350 europe austria - wels tel: 43-7242-2244-3910 fax: 43-7242-2244-393 denmark - copenhagen tel: 45-4450-2828 fax: 45-4485-2829 france - paris tel: 33-1-69-53-63-20 fax: 33-1-69-30-90-79 germany - munich tel: 49-89-627-144-0 fax: 49-89-627-144-44 italy - milan tel: 39-0331-742611 fax: 39-0331-466781 netherlands - drunen tel: 31-416-690399 fax: 31-416-690340 spain - madrid tel: 34-91-708-08-90 fax: 34-91-708-08-91 uk - wokingham tel: 44-118-921-5869 fax: 44-118-921-5820 w orldwide s ales and s ervice 06/08/06


▲Up To Search▲   

 
Price & Availability of AN1043

All Rights Reserved © IC-ON-LINE 2003 - 2022  

[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy]
Mirror Sites :  [www.datasheet.hk]   [www.maxim4u.com]  [www.ic-on-line.cn] [www.ic-on-line.com] [www.ic-on-line.net] [www.alldatasheet.com.cn] [www.gdcy.com]  [www.gdcy.net]


 . . . . .
  We use cookies to deliver the best possible web experience and assist with our advertising efforts. By continuing to use this site, you consent to the use of cookies. For more information on cookies, please take a look at our Privacy Policy. X